package com.church.daoimpl;

import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.church.dao.VideoDao;
import com.church.db.Video;

public class VideoDaoImpl extends HibernateDaoSupport implements VideoDao {

	@Override
	public String addVideo(Video video) {
		this.getHibernateTemplate().save(video);
		return "success";
	}

	@Override
	public Video getVideoById(int id) {
		List<Video> videos = this.getHibernateTemplate().find("from Video where id='"+id+"'");
		if(videos.size()>0)
		{
			return videos.get(0);
		}
		return null;
	}

	@Override
	public List<Video> getVideoList() {
		
		return this.getHibernateTemplate().find("from Video where state!='3'");
	}

	@Override
	public String updateVideo(Video video) {
		this.getHibernateTemplate().update(video);
		return "success";
	}

}
